define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: '/microend/userattribute/index',
                    add_url: '/microend/userattribute/add',
                    edit_url: '/microend/userattribute/edit',
                    del_url: '/microend/userattribute/del',
                    multi_url: '/microend/userattribute/multi',
                    table: 'user_attribute',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'attr_id',
                sortName: 'attr_id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'attr_id', title: __('Attr_id')},
                        {field: 'uid', title: __('Uid')},
                        {field: 'cash_status', title: __('Cash_status'), searchList: {"1":__('Cash_status 1'),"2":__('Cash_status 2')}, formatter: Table.api.formatter.status},
                        {field: 'single_status', title: __('Single_status'), searchList: {"1":__('Single_status 1'),"2":__('Single_status 2')}, formatter: Table.api.formatter.status},
                        {field: 'real_auth_status', title: __('Real_auth_status'), searchList: {"1":__('Real_auth_status 1'),"2":__('Real_auth_status 2')}, formatter: Table.api.formatter.status},
                        {field: 'task_status', title: __('Task_status'), searchList: {"1":__('Task_status 1'),"2":__('Task_status 2')}, formatter: Table.api.formatter.status},
                        {field: 'task_count', title: __('Task_count')},
                        {field: 'task_day_count', title: __('Task_day_count')},
                        {field: 'task_finish_count', title: __('Task_finish_count')},
                        {field: 'user_count', title: __('User_count')},
                        {field: 'person_count', title: __('Person_count')},
                        {field: 'task_limit_cash', title: __('Task_limit_cash'), operate:'BETWEEN'},
                        {field: 'remarks', title: __('Remarks')},
                        {field: 'group_time', title: __('Group_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'account_status', title: __('Account_status'), searchList: {"1":__('Account_status 1'),"2":__('Account_status 2')}, formatter: Table.api.formatter.status},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });



            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});